
class Security(object):
    code = None
    name = None
    def __str__(self):
        return "\t".join(map(str, [self.code, self.name]))


class Investor(object):

    id = None
    name = None

    def __str__(self):
        return "\t".join(map(str ,[self.id ,self.name]))


class News(object):
    address = None
    news_text = None
    time = None

    def __str__(self):
        return "\t".join(map(str ,[ self.address ,self.time ,self.news_text ,]))


class Senti(object):
    words = None
    sentences = None
    pos = None
    neg = None
    def __str__(self):
        return "\t".join(map(str ,[ self.words ,self.sentences ,self.pos ,self.neg]))

class Guba(object):
    secu = None
    read = None
    replay = None
    title = None
    url = None
    author = None
    time = None
    news = None
    senti = None

    def __str__(self):
        return "\t".join(map(str ,[self.secu ,self.author ,self.time ,self.url ,self.read ,self.replay ,self.title
                                   ,self.news, self.senti]))

    @staticmethod
    def head():
        return "\t".join \
            (["股票代码" ,"股票名称" ,"用户id" ,"用户名" ,"时间" ,"正文连接" ,"阅读量" ,"回复" ,"标题" ,"来源地址"
             ,"时间" ,"正文" ,"词语" ,"句子" ,"正面" ,"负面" ])
    @staticmethod
    def fromString(line):
        lst = line.split('\t')
        code ,secu_name =lst[0], lst[1]
        secu = Security()
        secu.code = code
        secu.name = secu_name

        id, name = lst[2], lst[3]
        time = lst[4]
        title = lst[8]
        url = lst[5]
        read = lst[6]
        replay = lst[7]
        address = lst[9]
        new_time = lst[10]
        news_text = lst[11]
        words = lst[12]
        sentence = lst[13]
        pos = lst[14]
        neg = lst[15]

        news = News()
        news.time = new_time
        news.address = address
        news.news_text = news_text

        author = Investor()
        author.id = id
        author.name = name

        guba = Guba()
        guba.secu = secu
        guba.author = author
        guba.title = title
        guba.replay = replay
        guba.time = time
        guba.url = url
        guba.read = read
        guba.news = news

        sen = Senti()
        sen.words = words
        sen.sentences = sentence
        sen.pos = pos
        sen.neg = neg

        guba.senti = sen
        return guba
